{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "#### Python 中的运算符\n",
    "变量和运算符可以组成表达式，表达式由多个变量，运算符和函数组合而成，编程语言可以对其解释和计算得到另一个值"
   ],
   "id": "c9abb345e1b5fa33"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "#运算符 优先级从高到低\n",
    "#### 索引和切片 []  [:]\n",
    "#### ** 幂运算\n",
    "#### ～ 按位取反 + 正号 - 负号\n",
    "#### * 乘 / 除 % 取模  // 整除\n",
    "#### + 加 - 减\n",
    "#### >> 右移 << 左移\n",
    "#### & 按位与\n",
    "#### <= < > >= 小于等于 小于 大于 大于等于\n",
    "#### == 等于 != 不等于\n",
    "#### is  is not 身份运算\n",
    "#### in  not in 成员运算\n",
    "#### not  or  and 逻辑运算\n",
    "#### = += -= *= /= %= //= **= &=  |= ^= >>= <<= 赋值运算符"
   ],
   "id": "bea03cbb28601e53"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-09T13:22:31.660206Z",
     "start_time": "2025-11-09T13:22:27.085628Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from symbol import and_expr\n",
    "from threading import main_thread\n",
    "\n",
    "a = 10\n",
    "b = 3\n",
    "a += b\n",
    "print(a)\n",
    "a *= a + 2  # a=a*(a+2)\n",
    "\n",
    "print(a)\n",
    "\n",
    "f = float(input('请输出华氏温度：'))\n",
    "c = (f - 32) / 1.8\n",
    "print(f'华氏温度 :{f:.1f} 对应的摄氏温度为 ：{c:.1f}')"
   ],
   "id": "f1668165d69717c4",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "13\n",
      "195\n",
      "华氏温度 :290.0 对应的摄氏温度为 ：143.3\n"
     ]
    }
   ],
   "execution_count": 6
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-09T13:27:54.585023Z",
     "start_time": "2025-11-09T13:27:49.428251Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#计算圆形的面积\n",
    "from math import pi\n",
    "\n",
    "radius = float(input('请输出圆形的半径 '))\n",
    "\n",
    "area = pi * radius ** 2\n",
    "perimeter = 2 * pi * radius\n",
    "\n",
    "print('圆形的面积为 %.2f' % area)\n",
    "#\n",
    "print(f'圆形的周长为 :{perimeter = :2 * pi * radius}')"
   ],
   "id": "414cf4f2d872b01f",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "圆形的面积为 969.49\n"
     ]
    }
   ],
   "execution_count": 7
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-09T14:38:40.749219Z",
     "start_time": "2025-11-09T14:38:37.366Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#判断闰年\n",
    "year = int(input('请输出年份'))\n",
    "\n",
    "is_leap = (year % 4 == 0 and year % 100 != 0) or (year %400==0)\n",
    "\n",
    "print(f'年份 {year:1d} 是否是闰年 :{is_leap}')\n",
    "\n"
   ],
   "id": "b708fb2e686bb33c",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "年份 2001 是否是闰年 :False\n"
     ]
    }
   ],
   "execution_count": 11
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
